﻿using MediatR;
using SheepStorage.API.Application.Command.TransferCommand;

using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.TransferHandler
{
	/// <summary>
	/// 后裔转种显示命令处理器
	/// </summary>
	public class TransferShowHandler : IRequestHandler<ProgenyTransferShowCommand, Results<PageOutput<ProgenyTransfer>>>
	{

		private readonly IProgenyTransferService service;

		public TransferShowHandler(IProgenyTransferService service)
		{
			this.service = service;
		}



		/// <summary>
		/// 后裔转种命令处理器
		/// </summary>
		/// <param name="request"></param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>

		public async Task<Results<PageOutput<ProgenyTransfer>>> Handle(ProgenyTransferShowCommand request, CancellationToken cancellationToken)
		{


			var entity = await service.GetProgenyTransfers(request.SatrtTransferDate, request.EndTransferDate, request.OverBit, request.PageIndex, request.PageSize);


			return Results<PageOutput<ProgenyTransfer>>.DataResult(entity);


		 
		}
	}
}
